hysop.core.mpi.topo_tools module

Tools hysop topologies

  • TopoTools

class hysop.core.mpi.topo_tools.TopoTools[source]

Bases: object

Static class providing tools to handle set of indices, message tags, and so on.

static compare_comm(comm_1, comm_2)[source]

Compare two mpi communicators.

Returns true if the two communicators are handles for the same group of proc and for the same communication context.

Warning : if comm_1 or comm_2 is invalid, the function will fail.

static compare_groups(comm_1, comm_2)[source]

Compare the groups of two mpi communicators.

Returns true if each comm handles the same group of mpi processes.

Warning : if comm_1 or comm_2 is invalid, the function will fail.

static convert_ranks(source, target)[source]

Find the values of ranks in target from ranks in source.

Parameters:
  • source (mpi communicators)

  • target (Returns a list 'ranks' such that ranks[i] = rank in)

  • target

  • source. (of process of rank i in)

static create_subarray(sl_dict, data_shape, order, mpi_type=None, dtype=None)[source]

Create a MPI subarray mask to be used in send/recv operations between some topologies.

Parameters:
  • sl_dict (dictionnary) – indices of the subarray for each rank, such that sl_dict[rk] = (slice(…), slice(…), …)

  • data_shape (shape (numpy-like) of the original array)

:param : :type : Returns : dictionnary of MPI derived types. :param Keys = ranks in parent communicator.:

static create_subarray_from_buffer(data, slices)[source]
static gather_global_indices(topo, toslice=True, root=None, comm=None)[source]

Collect global indices of local meshes on each process of topo

Parameters:
  • topo (CartesianTopology) – topology on which indices are collected.

  • toslice (boolean, optional) – true to return the result a dict of slices, else return a numpy array. See notes below.

  • root (int, optional) – rank of the root mpi process. If None, reduce operation is done on all processes.

  • comm (mpi communicator, optional) – Communicator used to reduce indices. Default = topo.parent

Returns:

  • either

  • * a dictionnary which maps rank number with

  • a list of slices such that res[rank][i] = a slice

  • defining the indices of the points of the local mesh,

  • in direction i, in global notation.

  • * or a numpy array where each column corresponds to a rank number,

  • with column = [start_x, end_x, start_y, end_y …]

  • Ranks number are the processes numbers in comm.

static gather_global_indices_overlap(topo=None, comm=None, dom=None, toslice=True, root=None)[source]

This functions does the same thing as gather_global_indices but may also work when topo is None.

The function is usefull if you need to collect global indices on a topo defined only on a subset of comm, when for the procs not in this subset, topo will be equal to None. In such a case, comm and dom are required. This may happen when you want to build a bridge between two topologies that do not handle the same number of processes but with an overlap between the two groups of processes of the topologies.

In that case, a call to gather_global_indices(topo, comm, dom) will work on all processes belonging to comm, topo being None or not. The values corresponding to ranks not in topo will be empty slices.

Parameters:
  • topo (CartesianTopology, optional) – topology on which indices are collected.

  • toslice (boolean, optional) – true to return the result a dict of slices, else return a numpy array. See notes below.

  • root (int, optional) – rank of the root mpi process. If None, reduce operation is done on all processes.

  • comm (mpi communicator, optional) – Communicator used to reduce indices. Default = topo.parent

  • dom (Domain) – current domain.

Returns:

  • either

  • * a dictionnary which maps rank number with

  • a list of slices such that res[rank][i] = a slice

  • defining the indices of the points of the local mesh,

  • in direction i, in global notation.

  • * or a numpy array where each column corresponds to a rank number,

  • with column = [start_x, end_x, start_y, end_y …]

  • Ranks number are the processes numbers in comm.

static initialize_tag_parameters(topo, group_size)[source]

Initialize tag_rank and tag_size, some parameters used to compute unique tag/ids for MPI messages.

Parameters:
  • topo (CartesianTopology)

  • group_size (numpy array) – size of groups of lines of particles in other directions than the current advection dir.

Notes

group_size shape == (problem dim - 1, problem dim) group_size[i, d] = size of groups in direction i when advection is performed in direction d.

static intersection_size(comm_1, comm_2)[source]

Number of processess common to comm_1 and comm_2

static is_parent(child, parent)[source]

Return true if all mpi processes of child belong to parent

static set_group_size(topo)[source]

Set default size for groups of lines of particles, depending on the local resolution

Parameters:

topo (CartesianTopology)

Notes

group_size shape == (problem dim - 1, problem dim) group_size[i, d] = size of groups in direction i when advection is performed in direction d.